<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" lang='en'>

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=9">
  <%- @current_tab_name = "admin" -%>
  <%- @view_title = @view_title || "Administration" -%>
  <%= render :partial => "shared/head" %>
</head>
<body id="<%= page_name %>" class="<%= page_name %>" <%= render "shared/body_data_attrs" %>>
<div class="page-wrap">
  <div id="body_bg">
    <%= render :partial => "shared/header" %>

    <div id='body_content'>
      <div class="messaging_wrapper" id="messaging_wrapper">
        <%= render :partial => "shared/flash_message" %>
        <%= render :partial => "shared/config_save_actions", :locals => {:scope => {}} -%>
      </div>

      <% if @in_pipeline_group_edit %>
          <div class="page_header">
            <div class="row">
              <h1 id="page-title" class="entity_title">
                <%= link_to 'Administration', spark_url_for({url_builder: controller}, SparkRoutes::AdminPipelines::SPA_BASE) -%>&nbsp;&raquo;
                <%= link_to 'Pipeline Groups', spark_url_for({url_builder: controller}, SparkRoutes::AdminPipelines::SPA_BASE) -%>&nbsp;&raquo;
                <%= @group.getGroup() -%>
              </h1>
            </div>
          </div>
      <% else %>
          <div class="page_header">
            <div class="row">
              <h1 id="page-title" class="entity_title">Administration</h1>
            </div>
          </div>
      <%- end -%>

      <% unless @config_valid %>
          <%== flash_message_pane_start("config_error", false) %>
          <p class="warning">Invalid config on disk. Displaying the last known valid config (Editing config through Go will overwrite the invalid copy. Edit it on disk to fix this problem).</p>
          <%== flash_message_pane_end %>
      <% end %>

      <%== content_wrapper_tag %>
      <div class="row">
        <div class="bd-container rounded-corner-for-pipeline admin-rounded-container">
          <div class="sub_tab_container rounded-corner-for-tab-container">
            <div class="sub_tabs_container">
              <ul>
                <% if is_user_an_admin? || is_user_a_group_admin? %>
                    <li id="pipeline-groups-tab-button" class="<%= "current_tab" if @tab_name == "pipeline-groups" %>">
                      <a id="tab-link-of-pipeline-groups" href="<%= spark_url_for({url_builder: controller}, SparkRoutes::AdminPipelines::SPA_BASE) -%>">Pipelines</a>
                    </li>
                <% end %>
                <% if is_user_an_admin? || is_user_authorized_to_view_templates? -%>
                    <li id="templates-tab-button" class="<%= "current_tab" if @tab_name == "templates" %>">
                      <a id="tab-link-of-templates" href="<%= spark_url_for({url_builder: controller}, SparkRoutes::AdminTemplates::SPA_BASE) -%>">Templates</a>
                    </li>
                <%- end -%>
                <% if !is_user_an_admin? && is_user_a_group_admin? %>
                    <li id="tab-content-of-pipelines-snippet" class="<%= "current_tab" if @tab_name == "pipelines-snippet" %>">
                      <%= link_to 'Config XML', pipelines_snippet_path, :id => "tab-link-of-pipelines-snippet" -%>
                    </li>
                    <li id="package-repositories-tab-button" class="<%= @tab_name == "package-repositories" ? "current_tab" : "" -%>">
                      <%= link_to 'Package Repositories', package_repositories_list_path, :id => "tab-link-of-package-repositories" %>
                    </li>
                <% end %>

                <% if is_user_an_admin? %>
                    <li id="source-xml-tab-button" class="<%= "current_tab" if @tab_name == "configuration-xml" %>">
                      <%= link_to 'Config XML', config_view_path, :id => 'tab-link-of-source-xml' -%>
                    </li>
                    <li id="user-summary-tab-button" class="<%= @tab_name == "user-listing" ? "current_tab" : "" -%>">
                      <%= link_to "Users Management", '/go/admin/users', :id => "tab-link-of-user-listing" %>
                    </li>
                    <li id="backup-tab-button" class="<%= @tab_name == "backup" ? "current_tab" : "" -%>">
                      <%= link_to "Backup", '/go/admin/backup', :id => "tab-link-of-backup" %>
                    </li>
                    <li id="package-repositories-tab-button" class="<%= @tab_name == "package-repositories" ? "current_tab" : "" -%>">
                      <%= link_to 'Package Repositories', package_repositories_new_path, :id => "tab-link-of-package-repositories" %>
                    </li>
                <% end %>
              </ul>
            </div>
            <div class="sub_tab_container_content admin-tab-contents">
              <div id="tab-content-of-<%= @tab_name -%>" style="">
                <%= yield %>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<%= end_content_wrapper %>
<%= render :partial => 'navigation_elements/footer' %>
</body>
</html>
